package com.lagou.controller;/**
 * Created by IntelliJ IDEA.
 * User: Yangdx.
 * Date: 2018/4/15.
 * Time: 18:36.
 * Tags: Code, we are serious.
 */

import com.lagou.bean.ConsumerComponent;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 跳转到登录页面
 *
 * @author
 * @create 2018-04-15 18:36
 **/
@RestController
public class Controller {
    @Autowired
    private ConsumerComponent component;

    @RequestMapping(value = "/sayHello", method = RequestMethod.GET)
    public String sayHello() {
        try {
            RpcContext.getContext().setAttachment("ipAddress2", RpcContext.getContext().getLocalHost());
            String hello = component.sayHello("world", 0);
            return "result :" + hello;
        } catch (Exception e) {
            e.printStackTrace();
            return "发生异常："+e.toString();
        }
    }

    @RequestMapping(value = "/sayHello2", method = RequestMethod.GET)
    public String sayHello2() {
        try {
            String hello = component.sayHello2("world", 0);
            return "result :" + hello;
        } catch (Exception e) {
            e.printStackTrace();
            return "发生异常："+e.toString();
        }
    }
}
